/**
 * Baijiahulian.com Inc. Copyright (c) 2014-2016 All Rights Reserved.
 */
package com.baijia.authentication.principal.resolver;

import com.baijia.authentication.AccountType;
import com.baijia.authentication.principal.Credentials;
import com.baijia.authentication.principal.credentials.OrgTeacherCredentials;
import com.baijia.common.enums.UserRoleType;

import com.google.common.collect.Maps;

import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @title UserPrincipalResolver
 * @desc TODO
 * @author macrohuang
 * @date Jan 20, 2016
 * @version 1.0
 */
@Component
public class OrgTeacherPrincipalResolver extends UserPrincipalResolver {

    @Override
    public boolean supports(Credentials credentials) {
        return credentials instanceof OrgTeacherCredentials;
    }

    @Override
    public int getAccountType() {
        return AccountType.ORG_TEACHER.getCode();
    }

    @Override
    protected Map<String, Object> generateAttributes(Credentials credentials) {
        Map<String, Object> attributes = Maps.newHashMap();
        attributes.put(Credentials.USER_ROLE, UserRoleType.ORG_TEACHER.getId());

        return attributes;
    }
}